import os
import urllib

import webapp2
from google.appengine.ext.webapp import template
from google.appengine.api import urlfetch
from google.appengine.api import users

class mainpage(webapp2.RequestHandler):
    def get(self):
        user = users.get_current_user()
        login_url = users.create_login_url(urllib.unquote_plus(self.request.uri))
        templatedic = { 'user': user,
                        'host_url': self.request.host_url,
                        'login_url': login_url}
        
        path = os.path.join(os.path.dirname(__file__), 'template', 'index.html')
        self.response.write(unicode(template.render(path, templatedic)))
        return

app = webapp2.WSGIApplication([
    ('/',mainpage),
    ('/index.html',mainpage)
], debug=True)